Time-frequency analysis of power

Table of Contents

Background

Time-frequency representations of power are used to quantify brain responses in the frequency domain. These reposes are often interpreted to reflect task-related modulations of brain oscillations. In this section we will show how these response can be estimated by an FFT approach using a sliding time-window.

Requirements

The FIFF-file with the raw data:
training_raw-1.fif training_raw-2.fif
Sensors and trials left from Artifact rejection:
chan_keep.mattrl_keep.matchan_keep2.mattrl_keep2.mat
The ICA projection from Artifact suppression by ICA:
planar_comp.mat
The trial function:
ft_trialfun_general.m

Preparing the data

dataset{1,1} = 'training_raw-1.fif';
dataset{1,2} = 'training_raw-2.fif';
Before initiating the TFR analysis read in the trials. Read in the trials:
for i=1:2
cfg = [];
cfg.dataset = char(dataset{1,i});
cfg.trialfun = 'ft_trialfun_general';
cfg.trialdef.eventtype = 'STI101';
cfg.trialdef.eventvalue = [21 22];
cfg.trialdef.prestim = 2.5;
cfg.trialdef.poststim = 2;
cfg = ft_definetrial(cfg);
cfg.channel = {'MEGGRAD'};
cfg.demean = 'yes';
data(i,1) = ft_preprocessing(cfg);
end
evaluating trialfunction 'ft_trialfun_general' reading the header from 'training_raw-1.fif' Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-1.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-1.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 208000 ... 1664999 = 208.000 ... 1664.999 secs Ready. reading the events from 'training_raw-1.fif' Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-1.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-1.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 208000 ... 1664999 = 208.000 ... 1664.999 secs Ready. Reading 208000 ... 1664999 = 208.000 ... 1664.999 secs... [done] Reading 208000 ... 1664999 = 208.000 ... 1664.999 secs... [done] Fixing trigger at sample 331854 Fixing trigger at sample 838423 found 3359 events created 139 trials the call to "ft_definetrial" took 16 seconds
Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-1.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-1.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 208000 ... 1664999 = 208.000 ... 1664.999 secs Ready. processing channel { 'MEG0112' 'MEG0113' 'MEG0122' 'MEG0123' 'MEG0132' 'MEG0133' 'MEG0142' 'MEG0143' 'MEG0212' 'MEG0213' 'MEG0222' 'MEG0223' 'MEG0232' 'MEG0233' 'MEG0242' 'MEG0243' 'MEG0312' 'MEG0313' 'MEG0322' 'MEG0323' 'MEG0332' 'MEG0333' 'MEG0342' 'MEG0343' 'MEG0412' 'MEG0413' 'MEG0422' 'MEG0423' 'MEG0432' 'MEG0433' 'MEG0442' 'MEG0443' 'MEG0512' 'MEG0513' 'MEG0522' 'MEG0523' 'MEG0532' 'MEG0533' 'MEG0542' 'MEG0543' 'MEG0612' 'MEG0613' 'MEG0622' 'MEG0623' 'MEG0632' 'MEG0633' 'MEG0642' 'MEG0643' 'MEG0712' 'MEG0713' 'MEG0722' 'MEG0723' 'MEG0732' 'MEG0733' 'MEG0742' 'MEG0743' 'MEG0812' 'MEG0813' 'MEG0822' 'MEG0823' 'MEG0912' 'MEG0913' 'MEG0922' 'MEG0923' 'MEG0932' 'MEG0933' 'MEG0942' 'MEG0943' 'MEG1012' 'MEG1013' 'MEG1022' 'MEG1023' 'MEG1032' 'MEG1033' 'MEG1042' 'MEG1043' 'MEG1112' 'MEG1113' 'MEG1122' 'MEG1123' 'MEG1132' 'MEG1133' 'MEG1142' 'MEG1143' 'MEG1212' 'MEG1213' 'MEG1222' 'MEG1223' 'MEG1232' 'MEG1233' 'MEG1242' 'MEG1243' 'MEG1312' 'MEG1313' 'MEG1322' 'MEG1323' 'MEG1332' 'MEG1333' 'MEG1342' 'MEG1343' 'MEG1412' 'MEG1413' 'MEG1422' 'MEG1423' 'MEG1432' 'MEG1433' 'MEG1442' 'MEG1443' 'MEG1512' 'MEG1513' 'MEG1522' 'MEG1523' 'MEG1532' 'MEG1533' 'MEG1542' 'MEG1543' 'MEG1612' 'MEG1613' 'MEG1622' 'MEG1623' 'MEG1632' 'MEG1633' 'MEG1642' 'MEG1643' 'MEG1712' 'MEG1713' 'MEG1722' 'MEG1723' 'MEG1732' 'MEG1733' 'MEG1742' 'MEG1743' 'MEG1812' 'MEG1813' 'MEG1822' 'MEG1823' 'MEG1832' 'MEG1833' 'MEG1842' 'MEG1843' 'MEG1912' 'MEG1913' 'MEG1922' 'MEG1923' 'MEG1932' 'MEG1933' 'MEG1942' 'MEG1943' 'MEG2012' 'MEG2013' 'MEG2022' 'MEG2023' 'MEG2032' 'MEG2033' 'MEG2042' 'MEG2043' 'MEG2112' 'MEG2113' 'MEG2122' 'MEG2123' 'MEG2132' 'MEG2133' 'MEG2142' 'MEG2143' 'MEG2212' 'MEG2213' 'MEG2222' 'MEG2223' 'MEG2232' 'MEG2233' 'MEG2242' 'MEG2243' 'MEG2312' 'MEG2313' 'MEG2322' 'MEG2323' 'MEG2332' 'MEG2333' 'MEG2342' 'MEG2343' 'MEG2412' 'MEG2413' 'MEG2422' 'MEG2423' 'MEG2432' 'MEG2433' 'MEG2442' 'MEG2443' 'MEG2512' 'MEG2513' 'MEG2522' 'MEG2523' 'MEG2532' 'MEG2533' 'MEG2542' 'MEG2543' 'MEG2612' 'MEG2613' 'MEG2622' 'MEG2623' 'MEG2632' 'MEG2633' 'MEG2642' 'MEG2643' } reading and preprocessing Reading 232279 ... 236778 = 232.279 ... 236.778 secs... [done] reading and preprocessing trial 2 from 139 Reading 239077 ... 243576 = 239.077 ... 243.576 secs... [done] Reading 246925 ... 251424 reading and preprocessing trial 4 from 139 Reading 254139 ... 258638 = 254.139 ... 258.638 secs... [done] Reading 262922 ... 267421 reading and preprocessing trial 6 from 139 Reading 270953 ... 275452 reading and preprocessing trial 7 from 139 Reading 279052 ... 283551 reading and preprocessing trial 8 from 139 Reading 288151 ... 292650 = 288.151 ... 292.650 secs... [done] Reading 297250 ... 301749 reading and preprocessing trial 10 from 139 Reading 304073 ... 308572 = 304.073 ... 308.572 secs... [done] Reading 310987 ... 315486reading and preprocessing trial 12 from 139 Reading 318952 ... 323451 = 318.952 ... 323.451 secs... [done] Reading 327685 ... 332184reading and preprocessing trial 14 from 139 Reading 336942 ... 341441 = 336.942 ... 341.441 secs... [done] Reading 344966 ... 349465reading and preprocessing trial 16 from 139 Reading 353873 ... 358372 = 353.873 ... 358.372 secs... [done] Reading 362839 ... 367338reading and preprocessing trial 18 from 139 Reading 369803 ... 374302 = 369.803 ... 374.302 secs... [done] Reading 377435 ... 381934reading and preprocessing trial 20 from 139 Reading 386368 ... 390867 = 386.368 ... 390.867 secs... [done] Reading 394191 ... 398690reading and preprocessing trial 22 from 139 Reading 402289 ... 406788 = 402.289 ... 406.788 secs... [done] Reading 411547 ... 416046reading and preprocessing trial 24 from 139 Reading 419604 ... 424103reading and preprocessing trial 25 from 139 Reading 426835 ... 431334reading and preprocessing trial 26 from 139 Reading 434416 ... 438915 = 434.416 ... 438.915 secs... [done] Reading 453674 ... 458173reading and preprocessing trial 28 from 139 Reading 462565 ... 467064reading and preprocessing trial 29 from 139 Reading 471823 ... 476322reading and preprocessing trial 30 from 139 Reading 481081 ... 485580reading and preprocessing trial 31 from 139 Reading 490047 ... 494546 = 490.047 ... 494.546 secs... [done] Reading 498771 ... 503270reading and preprocessing trial 33 from 139 Reading 505835 ... 510334reading and preprocessing trial 34 from 139 Reading 514784 ... 519283reading and preprocessing trial 35 from 139 Reading 523667 ... 528166 = 523.667 ... 528.166 secs... [done] Reading 530839 ... 535338reading and preprocessing trial 37 from 139 Reading 538571 ... 543070reading and preprocessing trial 38 from 139 Reading 546761 ... 551260 = 546.761 ... 551.260 secs... [done] Reading 554668 ... 559167reading and preprocessing trial 40 from 139 Reading 562858 ... 567357reading and preprocessing trial 41 from 139 Reading 570473 ... 574972reading and preprocessing trial 42 from 139 Reading 577787 ... 582286 = 577.787 ... 582.286 secs... [done] Reading 585752 ... 590251reading and preprocessing trial 44 from 139 Reading 593059 ... 597558 = 593.059 ... 597.558 secs... [done] Reading 600073 ... 604572reading and preprocessing trial 46 from 139 Reading 608980 ... 613479 = 608.980 ... 613.479 secs... [done] Reading 617863 ... 622362reading and preprocessing trial 48 from 139 Reading 626562 ... 631061reading and preprocessing trial 49 from 139 Reading 634293 ... 638792 = 634.293 ... 638.792 secs... [done] Reading 643159 ... 647658reading and preprocessing trial 51 from 139 Reading 650891 ... 655390reading and preprocessing trial 52 from 139 Reading 658005 ... 662504 = 658.005 ... 662.504 secs... [done] Reading 695220 ... 699719reading and preprocessing trial 54 from 139 Reading 704211 ... 708710 = 704.211 ... 708.710 secs... [done] Reading 713135 ... 717634reading and preprocessing trial 56 from 139 Reading 721434 ... 725933 = 721.434 ... 725.933 secs... [done] Reading 730358 ... 734857reading and preprocessing trial 58 from 139 Reading 737389 ... 741888 = 737.389 ... 741.888 secs... [done] Reading 744920 ... 749419reading and preprocessing trial 60 from 139 Reading 751809 ... 756308reading and preprocessing trial 61 from 139 Reading 760558 ... 765057reading and preprocessing trial 62 from 139 Reading 768965 ... 773464 = 768.965 ... 773.464 secs... [done] Reading 777898 ... 782397reading and preprocessing trial 64 from 139 Reading 786922 ... 791421 = 786.922 ... 791.421 secs... [done] Reading 795229 ... 799728reading and preprocessing trial 66 from 139 Reading 803203 ... 807702reading and preprocessing trial 67 from 139 Reading 811952 ... 816451reading and preprocessing trial 68 from 139 Reading 820718 ... 825217 = 820.718 ... 825.217 secs... [done] Reading 829442 ... 833941reading and preprocessing trial 70 from 139 Reading 838699 ... 843198reading and preprocessing trial 71 from 139 Reading 847690 ... 852189reading and preprocessing trial 72 from 139 Reading 855605 ... 860104 = 855.605 ... 860.104 secs... [done] Reading 864354 ... 868853reading and preprocessing trial 74 from 139 Reading 873045 ... 877544 = 873.045 ... 877.544 secs... [done] Reading 881402 ... 885901reading and preprocessing trial 76 from 139 Reading 888900 ... 893399 = 888.900 ... 893.399 secs... [done] Reading 898158 ... 902657reading and preprocessing trial 78 from 139 Reading 906506 ... 911005reading and preprocessing trial 79 from 139 Reading 963354 ... 967853reading and preprocessing trial 80 from 139 Reading 972437 ... 976936reading and preprocessing trial 81 from 139 Reading 980444 ... 984943reading and preprocessing trial 82 from 139 Reading 989702 ... 994201reading and preprocessing trial 83 from 139 Reading 998042 ... 1002541 = 998.042 ... 1002.541 secs... [done] Reading 1005115 ... 1009614reading and preprocessing trial 85 from 139 Reading 1013555 ... 1018054 = 1013.555 ... 1018.054 secs... [done] Reading 1020878 ... 1025377reading and preprocessing trial 87 from 139 Reading 1028968 ... 1033467reading and preprocessing trial 88 from 139 Reading 1036558 ... 1041057reading and preprocessing trial 89 from 139 Reading 1043923 ... 1048422 = 1043.923 ... 1048.422 secs... [done] Reading 1052355 ... 1056854reading and preprocessing trial 91 from 139 Reading 1060620 ... 1065119 = 1060.620 ... 1065.119 secs... [done] Reading 1069878 ... 1074377reading and preprocessing trial 93 from 139 Reading 1078393 ... 1082892reading and preprocessing trial 94 from 139 Reading 1087126 ... 1091625reading and preprocessing trial 95 from 139 Reading 1094574 ... 1099073 = 1094.574 ... 1099.073 secs... [done] Reading 1102756 ... 1107255reading and preprocessing trial 97 from 139 Reading 1110662 ... 1115161reading and preprocessing trial 98 from 139 Reading 1118561 ... 1123060reading and preprocessing trial 99 from 139 Reading 1125942 ... 1130441reading and preprocessing trial 100 from 139 Reading 1134883 ... 113938reading and preprocessing trial 101 from 139 Reading 1143632 ... 114813reading and preprocessing trial 102 from 139 Reading 1150938 ... 1155437 = 1150.938 ... 1155.437 secs... [done] Reading 1159804 ... 116430reading and preprocessing trial 104 from 139 Reading 1168895 ... 1173394 = 1168.895 ... 1173.394 secs... [done] Reading 1380215 ... 138471reading and preprocessing trial 106 from 139 Reading 1388363 ... 1392862 = 1388.363 ... 1392.862 secs... [done] Reading 1396562 ... 140106reading and preprocessing trial 108 from 139 Reading 1405820 ... 141031reading and preprocessing trial 109 from 139 Reading 1414736 ... 1419235 = 1414.736 ... 1419.235 secs... [done] Reading 1423993 ... 142849reading and preprocessing trial 111 from 139 Reading 1432217 ... 143671reading and preprocessing trial 112 from 139 Reading 1439290 ... 1443789 = 1439.290 ... 1443.789 secs... [done] Reading 1446220 ... 145071reading and preprocessing trial 114 from 139 Reading 1453068 ... 1457567 = 1453.068 ... 1457.567 secs... [done] Reading 1461500 ... 146599reading and preprocessing trial 116 from 139 Reading 1468356 ... 147285reading and preprocessing trial 117 from 139 Reading 1475996 ... 148049reading and preprocessing trial 118 from 139 Reading 1484444 ... 1488943 = 1484.444 ... 1488.943 secs... [done] Reading 1491083 ... 149558reading and preprocessing trial 120 from 139 Reading 1498198 ... 150269reading and preprocessing trial 121 from 139 Reading 1505229 ... 1509728 = 1505.229 ... 1509.728 secs... [done] Reading 1512360 ... 151685reading and preprocessing trial 123 from 139 Reading 1520792 ... 1525291 = 1520.792 ... 1525.291 secs... [done] Reading 1527581 ... 153208reading and preprocessing trial 125 from 139 Reading 1534328 ... 1538827 = 1534.328 ... 1538.827 secs... [done] Reading 1541509 ... 154600reading and preprocessing trial 127 from 139 Reading 1549141 ... 155364reading and preprocessing trial 128 from 139 Reading 1557439 ... 156193reading and preprocessing trial 129 from 139 Reading 1565888 ... 157038reading and preprocessing trial 130 from 139 Reading 1574863 ... 157936reading and preprocessing trial 131 from 139 Reading 1590926 ... 159542reading and preprocessing trial 132 from 139 Reading 1597815 ... 160231reading and preprocessing trial 133 from 139 Reading 1605964 ... 1610463 = 1605.964 ... 1610.463 secs... [done] Reading 1612853 ... 161735reading and preprocessing trial 135 from 139 Reading 1620993 ... 162549reading and preprocessing trial 136 from 139 Reading 1629525 ... 1634024 = 1629.525 ... 1634.024 secs... [done] Reading 1636606 ... 164110reading and preprocessing trial 138 from 139 Reading 1643737 ... 164823reading and preprocessing trial 139 from 139 Reading 1652995 ... 1657494 = 1652.995 ... 1657.494 secs... [done] the call to "ft_preprocessing" took 15 seconds
evaluating trialfunction 'ft_trialfun_general' reading the header from 'training_raw-2.fif' Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-2.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-2.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 1665000 ... 3098999 = 1665.000 ... 3098.999 secs Ready. reading the events from 'training_raw-2.fif' Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-2.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-2.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 1665000 ... 3098999 = 1665.000 ... 3098.999 secs Ready. Reading 1665000 ... 3098999 = 1665.000 ... 3098.999 secs... [done] Reading 1665000 ... 3098999 = 1665.000 ... 3098.999 secs... [done] found 4129 events created 172 trials the call to "ft_definetrial" took 17 seconds
Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle 306 MEG channel locations transformed Reading training_raw-2.fif ... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Opening raw data file training_raw-2.fif... Read a total of 8 projection items: generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle generated with autossp-1.2.0 (1 x 306) idle Range : 1665000 ... 3098999 = 1665.000 ... 3098.999 secs Ready. processing channel { 'MEG0112' 'MEG0113' 'MEG0122' 'MEG0123' 'MEG0132' 'MEG0133' 'MEG0142' 'MEG0143' 'MEG0212' 'MEG0213' 'MEG0222' 'MEG0223' 'MEG0232' 'MEG0233' 'MEG0242' 'MEG0243' 'MEG0312' 'MEG0313' 'MEG0322' 'MEG0323' 'MEG0332' 'MEG0333' 'MEG0342' 'MEG0343' 'MEG0412' 'MEG0413' 'MEG0422' 'MEG0423' 'MEG0432' 'MEG0433' 'MEG0442' 'MEG0443' 'MEG0512' 'MEG0513' 'MEG0522' 'MEG0523' 'MEG0532' 'MEG0533' 'MEG0542' 'MEG0543' 'MEG0612' 'MEG0613' 'MEG0622' 'MEG0623' 'MEG0632' 'MEG0633' 'MEG0642' 'MEG0643' 'MEG0712' 'MEG0713' 'MEG0722' 'MEG0723' 'MEG0732' 'MEG0733' 'MEG0742' 'MEG0743' 'MEG0812' 'MEG0813' 'MEG0822' 'MEG0823' 'MEG0912' 'MEG0913' 'MEG0922' 'MEG0923' 'MEG0932' 'MEG0933' 'MEG0942' 'MEG0943' 'MEG1012' 'MEG1013' 'MEG1022' 'MEG1023' 'MEG1032' 'MEG1033' 'MEG1042' 'MEG1043' 'MEG1112' 'MEG1113' 'MEG1122' 'MEG1123' 'MEG1132' 'MEG1133' 'MEG1142' 'MEG1143' 'MEG1212' 'MEG1213' 'MEG1222' 'MEG1223' 'MEG1232' 'MEG1233' 'MEG1242' 'MEG1243' 'MEG1312' 'MEG1313' 'MEG1322' 'MEG1323' 'MEG1332' 'MEG1333' 'MEG1342' 'MEG1343' 'MEG1412' 'MEG1413' 'MEG1422' 'MEG1423' 'MEG1432' 'MEG1433' 'MEG1442' 'MEG1443' 'MEG1512' 'MEG1513' 'MEG1522' 'MEG1523' 'MEG1532' 'MEG1533' 'MEG1542' 'MEG1543' 'MEG1612' 'MEG1613' 'MEG1622' 'MEG1623' 'MEG1632' 'MEG1633' 'MEG1642' 'MEG1643' 'MEG1712' 'MEG1713' 'MEG1722' 'MEG1723' 'MEG1732' 'MEG1733' 'MEG1742' 'MEG1743' 'MEG1812' 'MEG1813' 'MEG1822' 'MEG1823' 'MEG1832' 'MEG1833' 'MEG1842' 'MEG1843' 'MEG1912' 'MEG1913' 'MEG1922' 'MEG1923' 'MEG1932' 'MEG1933' 'MEG1942' 'MEG1943' 'MEG2012' 'MEG2013' 'MEG2022' 'MEG2023' 'MEG2032' 'MEG2033' 'MEG2042' 'MEG2043' 'MEG2112' 'MEG2113' 'MEG2122' 'MEG2123' 'MEG2132' 'MEG2133' 'MEG2142' 'MEG2143' 'MEG2212' 'MEG2213' 'MEG2222' 'MEG2223' 'MEG2232' 'MEG2233' 'MEG2242' 'MEG2243' 'MEG2312' 'MEG2313' 'MEG2322' 'MEG2323' 'MEG2332' 'MEG2333' 'MEG2342' 'MEG2343' 'MEG2412' 'MEG2413' 'MEG2422' 'MEG2423' 'MEG2432' 'MEG2433' 'MEG2442' 'MEG2443' 'MEG2512' 'MEG2513' 'MEG2522' 'MEG2523' 'MEG2532' 'MEG2533' 'MEG2542' 'MEG2543' 'MEG2612' 'MEG2613' 'MEG2622' 'MEG2623' 'MEG2632' 'MEG2633' 'MEG2642' 'MEG2643' } reading and preprocessing Reading 1668483 ... 1672982 = 1668.483 ... 1672.982 secs... [done] reading and preprocessing trial 2 from 172 Reading 1675214 ... 1679713 = 1675.214 ... 1679.713 secs... [done] Reading 1681978 ... 1686477 reading and preprocessing trial 4 from 172 Reading 1689142 ... 1693641 = 1689.142 ... 1693.641 secs... [done] Reading 1696390 ... 1700889 reading and preprocessing trial 6 from 172 Reading 1703221 ... 1707720 = 1703.221 ... 1707.720 secs... [done] Reading 1710310 ... 1714809 reading and preprocessing trial 8 from 172 Reading 1719293 ... 1723792 = 1719.293 ... 1723.792 secs... [done] Reading 1726349 ... 1730848 reading and preprocessing trial 10 from 172 Reading 1733697 ... 1738196reading and preprocessing trial 11 from 172 Reading 1742637 ... 1747136reading and preprocessing trial 12 from 172 Reading 1751895 ... 1756394reading and preprocessing trial 13 from 172 Reading 1758901 ... 1763400reading and preprocessing trial 14 from 172 Reading 1767400 ... 1771899reading and preprocessing trial 15 from 172 Reading 1774381 ... 1778880 = 1774.381 ... 1778.880 secs... [done] Reading 1781187 ... 1785686reading and preprocessing trial 17 from 172 Reading 1805949 ... 1810448reading and preprocessing trial 18 from 172 Reading 1815049 ... 1819548reading and preprocessing trial 19 from 172 Reading 1822155 ... 1826654reading and preprocessing trial 20 from 172 Reading 1830920 ... 1835419 = 1830.920 ... 1835.419 secs... [done] Reading 1838068 ... 1842567reading and preprocessing trial 22 from 172 Reading 1845182 ... 1849681reading and preprocessing trial 23 from 172 Reading 1854123 ... 1858622reading and preprocessing trial 24 from 172 Reading 1863064 ... 1867563reading and preprocessing trial 25 from 172 Reading 1870187 ... 1874686 = 1870.187 ... 1874.686 secs... [done] Reading 1877251 ... 1881750reading and preprocessing trial 27 from 172 Reading 1885083 ... 1889582reading and preprocessing trial 28 from 172 Reading 1894340 ... 1898839 = 1894.340 ... 1898.839 secs... [done] Reading 1902189 ... 1906688reading and preprocessing trial 30 from 172 Reading 1910963 ... 1915462 = 1910.963 ... 1915.462 secs... [done] Reading 1918077 ... 1922576reading and preprocessing trial 32 from 172 Reading 1926726 ... 1931225reading and preprocessing trial 33 from 172 Reading 1935742 ... 1940241 = 1935.742 ... 1940.241 secs... [done] Reading 1943632 ... 1948131reading and preprocessing trial 35 from 172 Reading 1950763 ... 1955262 = 1950.763 ... 1955.262 secs... [done] Reading 1959446 ... 1963945reading and preprocessing trial 37 from 172 Reading 1966743 ... 1971242reading and preprocessing trial 38 from 172 Reading 1976001 ... 1980500reading and preprocessing trial 39 from 172 Reading 1984967 ... 1989466 = 1984.967 ... 1989.466 secs... [done] Reading 1992165 ... 1996664reading and preprocessing trial 41 from 172 Reading 1999980 ... 2004479 = 1999.980 ... 2004.479 secs... [done] Reading 2009054 ... 2013553reading and preprocessing trial 43 from 172 Reading 2023716 ... 2028215 = 2023.716 ... 2028.215 secs... [done] Reading 2031214 ... 2035713reading and preprocessing trial 45 from 172 Reading 2038162 ... 2042661 = 2038.162 ... 2042.661 secs... [done] Reading 2045877 ... 2050376reading and preprocessing trial 47 from 172 Reading 2053475 ... 2057974reading and preprocessing trial 48 from 172 Reading 2062207 ... 2066706reading and preprocessing trial 49 from 172 Reading 2070097 ... 2074596reading and preprocessing trial 50 from 172 Reading 2076861 ... 2081360reading and preprocessing trial 51 from 172 Reading 2084493 ... 2088992 = 2084.493 ... 2088.992 secs... [done] Reading 2091532 ... 2096031reading and preprocessing trial 53 from 172 Reading 2100790 ... 2105289reading and preprocessing trial 54 from 172 Reading 2107504 ... 2112003reading and preprocessing trial 55 from 172 Reading 2115194 ... 2119693reading and preprocessing trial 56 from 172 Reading 2123968 ... 2128467reading and preprocessing trial 57 from 172 Reading 2131724 ... 2136223reading and preprocessing trial 58 from 172 Reading 2140515 ... 2145014reading and preprocessing trial 59 from 172 Reading 2148088 ... 2152587reading and preprocessing trial 60 from 172 Reading 2155870 ... 2160369reading and preprocessing trial 61 from 172 Reading 2163810 ... 2168309reading and preprocessing trial 62 from 172 Reading 2170799 ... 2175298reading and preprocessing trial 63 from 172 Reading 2180057 ... 2184556reading and preprocessing trial 64 from 172 Reading 2187855 ... 2192354reading and preprocessing trial 65 from 172 Reading 2195578 ... 2200077reading and preprocessing trial 66 from 172 Reading 2202776 ... 2207275reading and preprocessing trial 67 from 172 Reading 2210341 ... 2214840reading and preprocessing trial 68 from 172 Reading 2219056 ... 2223555reading and preprocessing trial 69 from 172 Reading 2233744 ... 2238243 = 2233.744 ... 2238.243 secs... [done] Reading 2241050 ... 2245549reading and preprocessing trial 71 from 172 Reading 2249999 ... 2254498 = 2249.999 ... 2254.498 secs... [done] Reading 2257489 ... 2261988reading and preprocessing trial 73 from 172 Reading 2265254 ... 2269753reading and preprocessing trial 74 from 172 Reading 2274161 ... 2278660reading and preprocessing trial 75 from 172 Reading 2282927 ... 2287426reading and preprocessing trial 76 from 172 Reading 2291209 ... 2295708reading and preprocessing trial 77 from 172 Reading 2298598 ... 2303097reading and preprocessing trial 78 from 172 Reading 2307414 ... 2311913reading and preprocessing trial 79 from 172 Reading 2315538 ... 2320037reading and preprocessing trial 80 from 172 Reading 2322944 ... 2327443reading and preprocessing trial 81 from 172 Reading 2330892 ... 2335391reading and preprocessing trial 82 from 172 Reading 2338841 ... 2343340reading and preprocessing trial 83 from 172 Reading 2347406 ... 2351905reading and preprocessing trial 84 from 172 Reading 2356664 ... 2361163reading and preprocessing trial 85 from 172 Reading 2365513 ... 2370012reading and preprocessing trial 86 from 172 Reading 2373553 ... 2378052reading and preprocessing trial 87 from 172 Reading 2381835 ... 2386334reading and preprocessing trial 88 from 172 Reading 2389992 ... 2394491reading and preprocessing trial 89 from 172 Reading 2397273 ... 2401772reading and preprocessing trial 90 from 172 Reading 2406531 ... 2411030reading and preprocessing trial 91 from 172 Reading 2415364 ... 2419863reading and preprocessing trial 92 from 172 Reading 2423946 ... 2428445reading and preprocessing trial 93 from 172 Reading 2431461 ... 2435960reading and preprocessing trial 94 from 172 Reading 2439509 ... 2444008reading and preprocessing trial 95 from 172 Reading 2454597 ... 2459096reading and preprocessing trial 96 from 172 Reading 2462370 ... 2466869reading and preprocessing trial 97 from 172 Reading 2470785 ... 2475284reading and preprocessing trial 98 from 172 Reading 2478784 ... 2483283reading and preprocessing trial 99 from 172 Reading 2487274 ... 2491773reading and preprocessing trial 100 from 172 Reading 2495631 ... 250013reading and preprocessing trial 101 from 172 Reading 2504739 ... 250923reading and preprocessing trial 102 from 172 Reading 2511620 ... 251611reading and preprocessing trial 103 from 172 Reading 2520878 ... 252537reading and preprocessing trial 104 from 172 Reading 2528659 ... 253315reading and preprocessing trial 105 from 172 Reading 2537801 ... 254230reading and preprocessing trial 106 from 172 Reading 2546483 ... 2550982 = 2546.483 ... 2550.982 secs... [done] Reading 2554414 ... 255891reading and preprocessing trial 108 from 172 Reading 2562396 ... 2566895 = 2562.396 ... 2566.895 secs... [done] Reading 2569119 ... 257361reading and preprocessing trial 110 from 172 Reading 2578251 ... 2582750 = 2578.251 ... 2582.750 secs... [done] Reading 2586717 ... 259121reading and preprocessing trial 112 from 172 Reading 2595791 ... 260029reading and preprocessing trial 113 from 172 Reading 2604282 ... 260878reading and preprocessing trial 114 from 172 Reading 2612230 ... 2616729 = 2612.230 ... 2616.729 secs... [done] Reading 2620720 ... 262521reading and preprocessing trial 116 from 172 Reading 2627626 ... 263212reading and preprocessing trial 117 from 172 Reading 2634399 ... 2638898 = 2634.399 ... 2638.898 secs... [done] Reading 2642714 ... 264721reading and preprocessing trial 119 from 172 Reading 2651972 ... 2656471 = 2651.972 ... 2656.471 secs... [done] Reading 2660638 ... 266513reading and preprocessing trial 121 from 172 Reading 2675975 ... 268047reading and preprocessing trial 122 from 172 Reading 2684724 ... 268922reading and preprocessing trial 123 from 172 Reading 2692331 ... 2696830 = 2692.331 ... 2696.830 secs... [done] Reading 2700504 ... 270500reading and preprocessing trial 125 from 172 Reading 2708653 ... 271315reading and preprocessing trial 126 from 172 Reading 2716968 ... 272146reading and preprocessing trial 127 from 172 Reading 2724958 ... 272945reading and preprocessing trial 128 from 172 Reading 2731789 ... 273628reading and preprocessing trial 129 from 172 Reading 2740513 ... 274501reading and preprocessing trial 130 from 172 Reading 2748462 ... 275296reading and preprocessing trial 131 from 172 Reading 2756485 ... 276098reading and preprocessing trial 132 from 172 Reading 2764133 ... 276863reading and preprocessing trial 133 from 172 Reading 2771681 ... 277618reading and preprocessing trial 134 from 172 Reading 2778512 ... 278301reading and preprocessing trial 135 from 172 Reading 2786235 ... 279073reading and preprocessing trial 136 from 172 Reading 2794584 ... 279908reading and preprocessing trial 137 from 172 Reading 2803842 ... 280834reading and preprocessing trial 138 from 172 Reading 2812024 ... 281652reading and preprocessing trial 139 from 172 Reading 2819738 ... 282423reading and preprocessing trial 140 from 172 Reading 2828487 ... 283298reading and preprocessing trial 141 from 172 Reading 2836803 ... 284130reading and preprocessing trial 142 from 172 Reading 2844534 ... 284903reading and preprocessing trial 143 from 172 Reading 2853792 ... 285829reading and preprocessing trial 144 from 172 Reading 2861857 ... 286635reading and preprocessing trial 145 from 172 Reading 2870656 ... 287515reading and preprocessing trial 146 from 172 Reading 2879380 ... 288387reading and preprocessing trial 147 from 172 Reading 2893667 ... 289816reading and preprocessing trial 148 from 172 Reading 2901090 ... 290558reading and preprocessing trial 149 from 172 Reading 2909706 ... 291420reading and preprocessing trial 150 from 172 Reading 2916645 ... 292114reading and preprocessing trial 151 from 172 Reading 2923634 ... 292813reading and preprocessing trial 152 from 172 Reading 2930382 ... 293488reading and preprocessing trial 153 from 172 Reading 2937246 ... 294174reading and preprocessing trial 154 from 172 Reading 2945828 ... 295032reading and preprocessing trial 155 from 172 Reading 2952534 ... 295703reading and preprocessing trial 156 from 172 Reading 2959440 ... 296393reading and preprocessing trial 157 from 172 Reading 2968456 ... 297295reading and preprocessing trial 158 from 172 Reading 2977497 ... 298199reading and preprocessing trial 159 from 172 Reading 2984511 ... 298901reading and preprocessing trial 160 from 172 Reading 2991617 ... 299611reading and preprocessing trial 161 from 172 Reading 3000875 ... 300537reading and preprocessing trial 162 from 172 Reading 3008122 ... 301262reading and preprocessing trial 163 from 172 Reading 3017380 ... 3021879 = 3017.380 ... 3021.879 secs... [done] Reading 3024294 ... 302879reading and preprocessing trial 165 from 172 Reading 3031200 ... 303569reading and preprocessing trial 166 from 172 Reading 3039791 ... 304429reading and preprocessing trial 167 from 172 Reading 3048440 ... 305293reading and preprocessing trial 168 from 172 Reading 3055888 ... 306038reading and preprocessing trial 169 from 172 Reading 3064653 ... 306915reading and preprocessing trial 170 from 172 Reading 3071785 ... 307628reading and preprocessing trial 171 from 172 Reading 3078957 ... 308345reading and preprocessing trial 172 from 172 Reading 3087731 ... 3092230 = 3087.731 ... 3092.230 secs... [done] the call to "ft_preprocessing" took 20 seconds
cfg=[];
cfg.keepsampleinfo='no';
data_planar=ft_appenddata(cfg,data(1,1),data(2,1));
concatenating over the "rpt" dimension the call to "ft_selectdata" took 0 seconds the call to "ft_appenddata" took 0 seconds
load trl_keep
load chan_keep
cfg=[];
cfg.trials=trl_keep;
cfg.channel=chan_keep;
planar_rjv1=ft_selectdata(cfg,data_planar);
the call to "ft_selectdata" took 1 seconds
Apply the ICA projection
load planar_comp
cfg = [];
cfg.component = [8 13];
planar_ica = ft_rejectcomponent(cfg, planar_comp, planar_rjv1);
undoing the comp balancing for the gradiometer definition
Warning: assuming that planar MEG channel units are T/cm
baseline correcting data removing 2 components keeping 201 components processing trials processing trial 287 from 287 also applying the backprojection matrix to the grad structure
Warning: copying input chantype to montage
Warning: copying input chanunit to montage
the call to "ft_rejectcomponent" took 8 seconds
Select 'attend left' trials and 'attend right' trials for the two conditions.
idx=(find(planar_ica.trialinfo==21))';
cfg=[];
cfg.trials=idx;
data_left=ft_selectdata(cfg,planar_ica);
Warning: assuming that planar MEG channel units are T/cm
the call to "ft_selectdata" took 0 seconds
clear idx
idx=(find(planar_ica.trialinfo==22))';
cfg=[];
cfg.trials=idx;
data_right=ft_selectdata(cfg,planar_ica);
the call to "ft_selectdata" took 0 seconds

Perform the time-frequency analysis of power; lower frequencies

The goal is to calculate the time-frequency of power per trials. The power will subsequently be averaged over trials. To calculate the power a Fourier transform is applied to a sliding time-window approach. The length of the time-window (cfg.t_fimwin) is ΔT = 0.5 s. It will be moved in time steps of 0.05 s starting at -1.5 and ending at 1 (cfg.toi). Prior to calculating the Fourier transform the time window is multiplied by a Hanning taper (also length ΔT). The analysis will be performed from 1 to 30 Hz in steps of Δf = 2 Hz (cfg.foi). Note that the frequency steps are dictated by the length of the sliding time-window: Δf = 1/ΔT. The spectra smoothing is about ΔFs = 1.5 / ΔT = ±3 Hz (the factor 1.5 stems for the Hanning taper).
Loc_eps_stft_spec.gif
Calculate the time-frequency power for both conditions:
cfg = [];
cfg.output = 'pow';
cfg.channel = 'MEGGRAD';
cfg.taper = 'hanning';
cfg.method = 'mtmconvol';
cfg.foi = 2:2:30;
numfoi = length(cfg.foi);
cfg.t_ftimwin = ones(length(cfg.foi),1).* 0.5;
cfg.toi = [-1.8 : 0.05: 1];
cfg.keeptrials = 'no';
tfr_low_left = ft_freqanalysis(cfg, data_left);
the input is raw data with 203 channels and 147 trials
Warning: sampleinfo in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous recording
the call to "ft_selectdata" took 0 seconds Default cfg.pad='maxperlen' can run slowly. Consider using cfg.pad='nextpow2' for more efficient FFT computation. processing trials trial 147, frequency 15 (30.00 Hz), 1 tapers the call to "ft_freqanalysis" took 57 seconds
tfr_low_right = ft_freqanalysis(cfg, data_right);
the input is raw data with 203 channels and 140 trials
Warning: sampleinfo in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous recording
the call to "ft_selectdata" took 0 seconds Default cfg.pad='maxperlen' can run slowly. Consider using cfg.pad='nextpow2' for more efficient FFT computation. processing trials trial 140, frequency 15 (30.00 Hz), 1 tapers the call to "ft_freqanalysis" took 53 seconds
The TFRs of power for the 203 planar gradiometers (remember we removed 1 sensor previously) have now been produced. Recall that the Elekta/MEGIN system has 306 sensor locations. Each location has two orthogonal planar gradiometers.
The next step is to combine the power of two gradiometers by a summing those:
cfg = [];
cfg.method = 'sum';
tfr_low_left_c = ft_combineplanar(cfg,tfr_low_left);
the input is freq data with 203 channels, 15 frequencybins and 57 timebins the call to "ft_combineplanar" took 0 seconds
tfr_low_right_c = ft_combineplanar(cfg,tfr_low_right);
the input is freq data with 203 channels, 15 frequencybins and 57 timebins the call to "ft_combineplanar" took 0 seconds
This results in 102 TFRs of each of the conditions.

Plotting the TFR of the low frequency results

In the following analysis we will focus on the time following the target onset and 'attend left' trials only. Lets first consider the TFR plot of a single location (MEG2112+MEG2113):
cfg = [];
cfg.baseline = 'no';
cfg.xlim = [-0.5 1];
cfg.zlim = [0 0.7e-23] ;
cfg.showlabels = 'no';
cfg.channel = 'MEG2112+2113';
ft_singleplotTFR(cfg, tfr_low_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the call to "ft_selectdata" took 0 seconds
the call to "ft_singleplotTFR" took 2 seconds
The power spans from 0 to 0.7e-23. The units are in (T/m)2/Hz. To convert to (fT/m)2/Hz multiply by 1026, i.e. the range is in 0 to 1500 (ft/m)2. In the plot note the ongoing alpha activity at ~10 Hz. In response to the cue and stimulus onset there is ~4 to 6 Hz response most likely reflecting the spectral content of the event-related field.
To observe the change in power we apply relative baseline (-0.5 to -0.3 s; i.e. just prior to the target onset) (powerpost/powerpre). Note ~100% decrease of power in the alpha band after the grating onset (time 0s) until the end of the analysed window. In addition note the short-lived over 100% response in the theta band at the grating onset. This respons in the theta band likely reflecting the spectral representation of the event-related field rather than induced oscillations.
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim = [-0.5 1];
cfg.zlim = [0.4 2] ;
cfg.showlabels = 'no';
cfg.channel = 'MEG2112+2113';
ft_singleplotTFR(cfg, tfr_low_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 15 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_singleplotTFR" took 1 seconds
To plot all sensors:
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim=[-0.5 1];
cfg.zlim = [0.4 2] ;
cfg.layout = 'neuromag306cmb.lay';
ft_multiplotTFR(cfg, tfr_low_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 15 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
the call to "ft_multiplotTFR" took 2 seconds

Exercise 1

Plot the results using an absolute baseline. Why is a relative baseline typically used in group studies?

Exercise 2

Change the time-window to 0.25 s and plot the results. What is the main effect in terms of time and frequency smoothing? Also show the updated cfg.

Exercise 3

Change the time-window to 1.00 s and plot the results. What is the main effect in terms of time and frequency smoothing? Also show the updated cfg.
The topographical representation can be plotted as follows:
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim=[0.35 1];
cfg.ylim = [10 10];
cfg.zlim = [0.5 1.5] ;
cfg.showlabels = 'no';
cfg.layout = 'neuromag306cmb.lay';
figure
ft_topoplotTFR(cfg, tfr_low_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
Warning: The field cfg.showlabels is forbidden, it will be removed from your configuration
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 15 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds

Exercise 4

Repeat the analysis with the 'attend right' trials. Are there any differences from the results of the 'attend left' trials?
Finally let's plot the difference between the 'attend left' and 'attend right' trials. To do so we calculate the difference between the two conditions divided by their sum.
tfr_low_diff=tfr_low_left_c;
tfr_low_diff.powspctrm=(tfr_low_left_c.powspctrm-tfr_low_right_c.powspctrm)./(tfr_low_left_c.powspctrm+tfr_low_right_c.powspctrm);
Then plot the resulting power estimates:
cfg = [];
cfg.xlim=[-1 1];
cfg.zlim = [-0.3 0.3] ;
cfg.showlabels = 'no';
cfg.layout = 'neuromag306cmb.lay';
ft_multiplotTFR(cfg, tfr_low_diff);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the call to "ft_selectdata" took 0 seconds reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
the call to "ft_multiplotTFR" took 2 seconds
Then plot the topography of the alpha repsonse at 10Hz and focus on the timewindow between the cue onset (-1.2 sec) and grating onset (0 sec). Lateralized attention shift has repeatedly been reported in the literature indexed by alpha power lateralization well after the cue just prior to the target onset.
cfg = [];
cfg.xlim = [-0.5 0];
cfg.ylim = [10 10];
cfg.zlim = [-0.2 0.2] ;
cfg.showlabels = 'no';
cfg.layout = 'neuromag306cmb.lay';
ft_topoplotTFR(cfg, tfr_low_diff);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
Warning: The field cfg.showlabels is forbidden, it will be removed from your configuration
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
The resulting plot indicate strong lateralization of the alpha response over a number of posterior channels when comparing the 'attend left' and 'attend right' trials.
To study the topography as a function of time write:
cfg = [];
cfg.xlim = [-0.6:0.2:0.6];
cfg.ylim = [10 10];
cfg.zlim = [-0.2 0.2] ;
cfg.showlabels = 'no';
cfg.layout = 'neuromag306cmb.lay';
ft_topoplotTFR(cfg, tfr_low_diff);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
Warning: The field cfg.showlabels is forbidden, it will be removed from your configuration
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the call to "ft_selectdata" took 0 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds
the call to "ft_prepare_layout" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_topoplotTFR" took 1 seconds the call to "ft_topoplotTFR" took 6 seconds

Perform the time-frequency analysis of power; higher frequencies

For higher frequencies, a multitaper approach is typically applied. The multitapers serve to smooth the time-frequency representations in the frequency domain. The smoothing will increase with number of tapers. Since oscillatory gamma activity (~60-90 Hz) often is quite broadband more spectral smoothing is required compared to lower frequencies. Several orthogonal tapers might be used for each time window prior to the calculation of the Fourier transform. The length of the time-window (cfg.t_fimwin) is ΔT = 0.25 s. It will be moved in steps of 0.05 s starting at -1.5 and ending at 1.5 (cfg.toi). The analysis will be performed from 30 to 100 Hz in steps of Δf = 4 Hz (cfg.foi) since the frequency steps are dependent on the length of the time-window ( Δf = 1/ΔT).
The number of tapers is dependent on ΔT and the required smoothing ΔFs. We chose ΔFs = 10 (cfg.tapsmofrq). The resulting tapers are defined as
K = 2*ΔT*ΔFs-1
where K is an integer required to be larger than 0.
i.e. K = 2*0.25 * 10 - 1 = 4 tapers. Note the smoothing is ±10 i.e. about 20 Hz total (see Percival and Walden, 1993). Also keep in mind that it does not make sense to reduce the smoothing to only having one taper. In that case use a Hanning taper instead.
Run the time-frequency analysis of power on the 'attend left' and 'attend right' trials separately.
cfg = [];
cfg.output = 'pow';
cfg.channel = 'MEGGRAD';
cfg.taper = 'dpss';
cfg.tapsmofrq = 10;
cfg.method = 'mtmconvol';
cfg.foi = 30:4:100;
numfoi = length(cfg.foi);
cfg.t_ftimwin = ones(length(cfg.foi),1).* 0.25;
cfg.toi = [-1.8 : 0.05: 1];
cfg.keeptrials = 'no';
tfr_high_left = ft_freqanalysis(cfg, data_left);
the input is raw data with 203 channels and 147 trials
Warning: sampleinfo in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous recording
the call to "ft_selectdata" took 0 seconds Default cfg.pad='maxperlen' can run slowly. Consider using cfg.pad='nextpow2' for more efficient FFT computation. processing trials trial 147, frequency 18 (98.00 Hz), 4 tapers the call to "ft_freqanalysis" took 262 seconds
tfr_high_right = ft_freqanalysis(cfg, data_right);
the input is raw data with 203 channels and 140 trials
Warning: sampleinfo in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous recording
the call to "ft_selectdata" took 0 seconds Default cfg.pad='maxperlen' can run slowly. Consider using cfg.pad='nextpow2' for more efficient FFT computation. processing trials trial 140, frequency 18 (98.00 Hz), 4 tapers the call to "ft_freqanalysis" took 249 seconds
Combine the power of two orthogonal gradiometers at the same location:
cfg = [];
cfg.method = 'sum';
tfr_high_left_c = ft_combineplanar(cfg,tfr_high_left);
the input is freq data with 203 channels, 18 frequencybins and 57 timebins the call to "ft_combineplanar" took 0 seconds
tfr_high_right_c = ft_combineplanar(cfg,tfr_high_right);
the input is freq data with 203 channels, 18 frequencybins and 57 timebins the call to "ft_combineplanar" took 0 seconds

Plotting the TFR of the high frequency results

The outcome of the TFR analysis of the 'attend left' trials will now be plotted with respect to a relative baseline (post-power / pre-power). The baseline interval is -0.5 to -0.3 s.
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim=[-0.5 1];
cfg.zlim = [0.6 1.4] ;
cfg.showlabels = 'no';
cfg.layout = 'neuromag306cmb.lay';
ft_multiplotTFR(cfg, tfr_high_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 18 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds reading layout from file neuromag306cmb.lay the call to "ft_prepare_layout" took 0 seconds
the call to "ft_multiplotTFR" took 2 seconds
The time-frequency response of the induced power. A relative baseline (-0.5 to -0.3 s) has been applied. Note the induced gamma band response over a couple of posterior sensors.
To plot a single location of the 'attend left' trials for the sensors MEG1922+1923 write:
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim=[-0.5 1];
cfg.zlim = [0.7 1.3] ;
cfg.showlabels = 'no';
cfg.channel = 'MEG1922+1923';
ft_singleplotTFR(cfg, tfr_high_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 18 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_singleplotTFR" took 0 seconds
This allows us to identify the time and frequency range of the gamma response.

Exercise 5

Perform the time-frequency analysis with a Hannning taper for the gamma band first with the 'attend left' trials:
cfg = [];
cfg.output = 'pow';
cfg.channel = 'MEGGRAD';
cfg.taper = 'hanning';
cfg.method = 'mtmconvol';
cfg.foi = 30:4:100;
cfg.t_ftimwin = ones(length(cfg.foi),1).* 0.25;
cfg.toi = [-1.8 : 0.05: 1];
cfg.keeptrials = 'no';
tfr_han_left = ft_freqanalysis(cfg, data_left);
the input is raw data with 203 channels and 147 trials
Warning: sampleinfo in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a continuous recording
the call to "ft_selectdata" took 0 seconds Default cfg.pad='maxperlen' can run slowly. Consider using cfg.pad='nextpow2' for more efficient FFT computation. processing trials trial 147, frequency 18 (98.00 Hz), 1 tapers the call to "ft_freqanalysis" took 64 seconds
cfg = [];
cfg.method = 'sum';
tfr_han_left_c = ft_combineplanar(cfg,tfr_han_left);
the input is freq data with 203 channels, 18 frequencybins and 57 timebins the call to "ft_combineplanar" took 0 seconds
cfg = [];
cfg.baseline = [-0.5 -0.3];
cfg.baselinetype = 'relative';
cfg.xlim=[-0.5 1];
cfg.zlim = [0.6 1.4] ;
cfg.showlabels = 'no';
cfg.channel = 'MEG1922+1923';
ft_singleplotTFR(cfg, tfr_han_left_c);
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
Warning: assuming that the default scaling should be amplitude/distance rather than amplitude
the input is freq data with 102 channels, 18 frequencybins and 57 timebins the call to "ft_freqbaseline" took 0 seconds the call to "ft_selectdata" took 0 seconds
the call to "ft_singleplotTFR" took 1 seconds
Do the same for the 'attend right' trials.
In which way does the multitapers improves the estimate and why?

Exercise 6

Change the smoothing to 20 Hz. How many tapers does this result in? What are the consequences for the time-frequency representation?

Exercise 7

Calculate and plot the difference between the 'attend left' and 'attend right' at 30Hz to 100Hz. Show the plots. Is there any difference between the two conditions in the gamma band?

Publications and preregistration

It is essential to report all the parameters in the frequency analysis both when submitting a preregistration and a manuscript. Note that the analysis based on a standard spectral analysis and should be independent on the toolbox applied.
Example for publications text: "The time-frequency representations were calculated using a sliding time-window approach applied to the single trials. For frequencies lower than 30 Hz we used a 500 ms time-window moved in steps of 50 ms. A Hanning window was multiplied to each time-window prior to calculating the discrete Fourier transform. This resulted in ±3 Hz spectral smoothing. The power was than estimated as the modulus square of the Fourier transform. This was done for 1 to 30 Hz in steps of 2 Hz.
For frequencies above 30 Hz a multi-taper method approach was used involving a sliding time-window of 0.25 s. To ensure sufficient spectral smoothing to the detect the gamma activity, a set of tapers derived from discrete prolate spheroidal (DPSS), or Slepian sequences, were multiplied to the time-windowed data. We used 4 tapers resulting in a spectral smoothing of ~±10 Hz. Following a discrete Fourier transform the power estimate for the respective tapers were averaged. This was done for 30 to 100 Hz in steps of 4 Hz.
The power-estimated per trial were averaged. The relative change in power was then considered with respect to a baseline of -0.3 to 0.5 ms. "

Background material